#ifndef MEMORYMANAGER_H_INCLUDED
#define MEMORYMANAGER_H_INC
#include<stdio.h>

#define INOUT
#define MM_HEAP_SIZE (64*1024)
#define MEM_UNIT     (8)

typedef enum err_MM {MM_ALL_OK,
MM_MANAGER_ALLOC_PROBLEMS=5,
MM_BITVECTOR_ALLOCATION_PROBLEMS=8,
MM_MALLOC_MEMORY_PROBLEMS=9,
MM_TO_LARGE_MEMORY_REQUEST=10,
MM_NON_ENOUGH_MEMORY=20,
MM_NOT_ACCEPT_MEM_MANAGER=30,
MM_NOT_ACCEPT_MEM_TO_FREE =40
} err_MM;

typedef struct MMheap MMheap;
struct MMheap
{
    size_t          size;/*Size of memory*/
    size_t          unitsize;
    void*           memory;
    unsigned char*  bv;
};
/*Destoy the MemoryManager*/
void MM_Destroy(MMheap* _memmang);
/*Accepts pointer to total Memory Block, and poiter to memory to free*/
err_MM MM_Free(MMheap* _memmang,void* _mem2free);
/*Accepts pointer to total Memory Block, and requested memory in bytes, returns the poiter to allocated block*/
void* MM_Malloc(MMheap* _memmang,size_t _size,INOUT err_MM* err);
/*Create of MemoryManager*/
MMheap* MM_Create(size_t _memsize, size_t _unitsize);

#endif /* MEMORYMANAGER_H_INCLUDED*/
